// 1.匹配指定 CSS 选择器的一个元素
const qs = (selector) => document.querySelector(selector);

// 2.匹配指定 CSS 选择器的所有元素
const qsAll = (selector) => document.querySelectorAll(selector);
// 获取表单数据
const getForm = (el) => {
  let formObj = {};
  qsAll(`${el} input[type=text]`).forEach(
    (ipt) => (formObj[ipt.name] = ipt.value)
  );
  qsAll(`${el} select`).forEach((sel) => (formObj[sel.name] = sel.value));
  qsAll(`${el} input[type=radio]`).forEach((ipt) => {
    if (ipt.checked) formObj[ipt.name] = ipt.value;
  });
  qsAll(`${el} input[type=hidden]`).forEach(item=>{
    formObj[item.name] = item.value
  })
  return formObj;
};
